//
//  BasNavViewController.swift
//  WeChat
//
//  Created by 梁迪 on 15/12/23.
//  Copyright © 2015年 梁迪. All rights reserved.
//

import UIKit

class BasNavViewController: UINavigationController,UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

    self.interactivePopGestureRecognizer?.delegate = self
    
    }

    override func pushViewController(viewController: UIViewController, animated: Bool) {
        if childViewControllers.count != 0 {
            let btn = UIButton(title: "返回", backImageName: nil, fontSize: 14, color: UIColor.lightGrayColor(), imageName: "BasNavViewController")
            btn.addTarget(self, action: "back", forControlEvents: .TouchUpInside)
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: btn)
            viewController.hidesBottomBarWhenPushed = true

            
        }
        super.pushViewController(viewController, animated: animated)
        
        
        
    }
    
    @objc private func back(){
        popViewControllerAnimated(true)
        
        
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        
        return childViewControllers.count != 1
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
